class AMap {
	static getProxyUrl(config) {
		if (!config.proxy || !config.url) return config;
		if (config.url instanceof Cesium.Resource) return config;
		var opts = {};
		for (var key in config) {
			opts[key] = config[key];
		}
		opts.url = new Cesium.Resource({
			url: opts.url,
			proxy: new Cesium.DefaultProxy(opts.proxy)
		});
		return opts;
	}
	static convertImageryLayer(opts){
		//高德
		var _url;
		switch (opts.layer) {
			case "vec":
			default:
				//style=7是立体的，style=8是灰色平面的
				_url = 'https://' + (opts.bigfont ? 'wprd' : 'webrd') + '0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}';
				break;
			case "img_d":
				_url = 'https://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}';
				break;
			case "img_z":
				_url = 'https://webst0{s}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8';
				break;
			case "time":
				var time = new Date().getTime();
				_url = 'https://tm.amap.com/trafficengine/mapabc/traffictile?v=1.0&;t=1&x={x}&y={y}&z={z}&&t=' + time;
				break;
		}

		if (opts.proxy) //存在代理时
			_url = (0, this.getProxyUrl)({ url: _url.replace('{s}', '1'), proxy: opts.proxy }).url;

		return new Cesium.UrlTemplateImageryProvider({
			url: _url,
			subdomains: ['1', '2', '3', '4'],
			maximumLevel: 18
		});
	}
}
export {AMap};